package net.liteheaven.xblib.common.log;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

/**
 * 日志实现
 * Created by liangy on 2016/11/1.
 */
public class Log4jImpl implements ILog {

    private static final String SEP = " >> ";
    private Logger logger;

    public Log4jImpl(){
        logger = Log4jManager.getInstance().getLogger();
    }

    public void d(String tag, String message) {

        if(logger != null && logger.isDebugEnabled()) {
            logger.debug(tag + SEP + message);
        }
    }

    public void i(String tag, String message) {
        if(logger != null && logger.isInfoEnabled()) {
            logger.info(tag + SEP + message);
        }
    }

    public void w(String tag, String message) {
        if(logger != null && logger.isEnabledFor(Level.WARN)) {
            logger.warn(tag + SEP + message);
        }
    }

    public void e(String tag, String message) {
        if(logger != null && logger.isEnabledFor(Level.ERROR)) {
            logger.error(tag + SEP + message);
        }
    }

    public void f(String tag, String message) {
        if(logger != null && logger.isEnabledFor(Level.FATAL)) {
            logger.fatal(tag + SEP + message);
        }
    }
}
